package de.fmaul.dicheck.model;

import java.util.Properties;

public class Property {
    public static final String DB_DRIVER = "database.driver";
    public static final String DB_CONNECTION = "database.connection";
    public static final String DB_ROLLBACK = "database.rollback";

    public static final String TEMPLATE_DIRECTORY = "template.directory";

    public static final String REPORT_TEMPLATE = "report.template";
    public static final String REPORT_OUTPUT_DIRECTORY = "report.output.directory";

    public static final String IGNORE_DIRS = "ignoreDirs";

    public static final String NAME = "name";
    public static final String DELAY = "delay";

    public static final String MAIL_ENABLED = "mail.enabled";
    public static final String MAIL_FROM = "mail.from";
    public static final String MAIL_TO = "mail.to";
    public static final String MAIL_TEMPLATE = "mail.template";

    public static int getInt(Properties properties, String propertyName) {
        final String value = properties.getProperty(propertyName, "0");

        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException e) {
            // TODO Auto-generated catch block
            return 0;
        }
    }

    public static boolean getBool(Properties properties, String propertyName,
            boolean defaultValue) {
        final String value = properties.getProperty(propertyName);

        if (value != null) {
            try {
                return Boolean.parseBoolean(value);
            } catch (NumberFormatException e) {
                // TODO Auto-generated catch block
                return defaultValue;
            }
        } else {
            return defaultValue;
        }

    }
    
    
    

}
